package nave;


public class Point implements Cloneable {
	/*
	 * Attributes
	 */
	public int x, y;

	/*
	 * Constructors
	 */
	public Point(int x, int y) {
		this.x = x;
		this.y = y;
	}
	public Point() {
		this(0,0);
	}

	/*
	 * Public methods
	 */
	public Point translate(Point p) {
	
		if ( p != null ) {
			this.x += p.x;
			this.y += p.y;
		}
		
		return this;
	}
	public Point translate(int x, int y) {
		return this.translate(new Point(x,y));
	}

	public Point setLocation(int x, int y) {
		this.x = x;
		this.y = y;
		
		return this;
	}

	@Override
	public Object clone() {
		return new Point(this.x, this.y);
	}

	@Override
	public boolean equals(Object obj) {
		if ( obj instanceof Point ) {
			Point p = (Point) obj;
			
			return ( this.x == p.x && this.y == p.y );
		}
		
		return false;
	}
	@Override
	public int hashCode() {
		return super.hashCode();
	}

}
